<%@page import="interfaces.DALException"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
    import="dto_objects.*"
    import="java.util.List"
    import="java.util.ArrayList"%>
<jsp:useBean id="func" class="Function.FunctionWEB" scope="session"/>     
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>Search</title>
	</head> 
	
<body>
	<div style="margin: auto; border: solid 1px; width: 600px; height: 600px;">
	
<form method="POST">
	<%
	
	out.print("<table id=\"tabledesign\" align=center border=solid 1px>");
	out.print("<tr>");
	out.print("<th>Search </th>");
	out.print("</tr>");
		out.print("<tr>");
		out.print("<td><input type=\"text\" name=\"Search\" value=\"\" size=4></td>"); 
		out.print("<td><input type=\"submit\" name=\"action\" value=\"Search\"></td>");
		out.print("</tr>");
	out.print("</table><br>");
%>
<%
if (request.getMethod().equals("POST") && request.getParameter("Search") != null){
	if(request.getParameter("action").equalsIgnoreCase("Search")){
		ArrayList<ArrayList> searchList = func.quickSearch(request.getParameter("Search"));
		for(int x=0;x<=searchList.size();x++){
			switch (x) {
		    case 0: 
		    	ArrayList<BookDTO> bookList = searchList.get(x);
		   		for(BookDTO tempBook : bookList){
		   			out.print(tempBook.getISBN()+"<br>");
		   			out.print(tempBook.getTitle()+"<br>");
		   			out.print(tempBook.getAuthors()+"<br>"+"<br>");
		   		}
		             break;
		    case 1: 
		    	ArrayList<AuthorDTO> authorList = searchList.get(x);
		   		for(AuthorDTO tempAuthor : authorList){
		   			out.print(tempAuthor.getAuthorFirstName()+" ");
		   			out.print(tempAuthor.getAuthorLastName()+"<br>");
		   			out.print(tempAuthor.getAuthorId()+"<br>"+"<br>");
		   		}
		             break;     
		    case 2: 
		    	ArrayList<SubjectDTO> subjectList = searchList.get(x);
		   		for(SubjectDTO tempSubject : subjectList){
		   			out.print(tempSubject.getSubject_name()+"<br>");
		   			out.print(tempSubject.getSubjectID()+"<br>"+"<br>");
		   		}
		             break; 
		    case 3: 
		    	ArrayList<PublisherDTO> publisherList = searchList.get(x);
		   		for(PublisherDTO tempPublisher : publisherList){
		   			out.print(tempPublisher.getPublisher_name()+"<br>");
		   			out.print(tempPublisher.getPublisherID()+"<br>"+"<br>");
		   		}
		             break; 
		             
		    default:
		    	out.print("<br>End of search");
		   			 break;
			}
		}
	}
}

%>

</form>
	</div>
</body>

</html>